﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data;
using MySql.Data.MySqlClient;
namespace LibSystem
{
    public partial class Form2 :Form
    {
        private MySqlConnection myconn;
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            textBox1.Text = DateTime.Now.ToString("h:mm:ss");
            timer1.Enabled = true;
            timer1.Interval = 100;
            this.Text = "图书管理系统 当前用户："+TempData.user;
            if (TempData.isManager) 管理ToolStripMenuItem.Enabled = true;
            else 管理ToolStripMenuItem.Enabled = false;
            String ss= "server=localhost;User Id=root;Database=libmanager;Persist Security Info=True";
            myconn = new MySqlConnection(ss);
            myconn.Open();
        }

        private void 关键字查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 child = new Form3(myconn,"BookName");
            child.MdiParent = this;
            child.Show();
            child.Text = "书名查询";
        }

        private void 出版社查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 child = new Form3(myconn,"Publisher");
            child.MdiParent = this;
            child.Show();
            child.Text = "出版社查询";
        }

        private void 作者查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 child = new Form3(myconn, "Writer");
            child.MdiParent = this;
            child.Show();
            child.Text = "作者查询";
        }

        private void 密码修改ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            PassChangeForm child = new PassChangeForm();
            child.MdiParent = this;
            child.Show();
        }

        private void 添加ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            managerForm child = new managerForm(myconn);
            child.MdiParent = this;
            child.Text = "添加图书";
            child.Show();
            
        }

        private void 修改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            managerForm child = new managerForm(myconn);
            child.MdiParent = this;
            child.Text = "修改图书";
            child.Show();
            
        }

        private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            managerForm child = new managerForm(myconn);
            child.MdiParent = this;
            child.Text = "删除图书";
            child.Show();
            
        }

        private void 管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            textBox1.Text = DateTime.Now.ToString("h:mm:ss");
        }
    }
}
